package de.koller.pulsar.scene.orbit;

import de.koller.aframe.util.resource.IOLoader;
import de.koller.oceanFramework.gl.util.RasterManager;
import de.koller.oceanFramework.math.RVec2;
import de.koller.oceanFramework.math.RVec2d;
import de.koller.pulsar.PNode;
import de.koller.pulsar.scene.IScene;
import java.util.Random;

public class OrbitScene extends PNode implements IScene {
	public final Random RND = new Random();
	public final int WIDTH = 1000, HEIGHT = 1000;
	
	private RasterManager raster = new RasterManager( WIDTH, HEIGHT );
	
	@Override
	protected void init() {
		super.init();

	}	
	
	@Override
	protected void update( int elapsedTime ) {
		super.update( elapsedTime );
	
		raster.clear( 0xff000000 );
	
		PlanetBodyTrail trail = new PlanetBodyTrail( 0, 0 );
		
		for( int t = 0; t < 2*Math.PI * 100; t++ ) {
			RVec2d p = trail.getPosition( t );
			raster.setPixel( 0xff_ffffff, (float)p.x + WIDTH/2, (float)p.y + WIDTH/2 );
		}
		
		RVec2 foci = new RVec2( WIDTH/2 + (float)Math.sqrt( 400*400 - 200*200 ), HEIGHT/2 );
		raster.setPixel( 0xff_ffff00, foci.x, foci.y );
				
		proot.setSceneFrame( IOLoader.create( raster ) );
	}

	
}
